#include <TrainerLib.h>
#include <iostream>
#include "resource.h"

#ifndef DEBUG
// Disable command prompt window
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif

int main(int argc, char* argv[])
{
	TLib::STrainer app("Halo", "Halo PC Trainer", 320, 256+25, IDI_ICON1, IDB_BITMAP1);
	app.setAboutInfo("Halo Trainer +8\n\nglass660@gmail.com");
	
	TLib::GEOMETRY_PARAMS geom;
	geom.x = 0;
	geom.y = 0;
	geom.w = 80;
	geom.h = 35;

	app.setOverrideButtonGeometry(TLib::BT_ABOUT, &geom);
	geom.x = 315 - geom.w;
	app.setOverrideButtonGeometry(TLib::BT_CHEATS, &geom);

	BYTE nops[] = {0x90,0x90,0x90,0x90,0x90,0x90,0x90};
	BYTE data1[] = {0xD9,0xEE,0x90,0x90,0x90,0x90};


	TLib::SCheat* unlimNades = new TLib::SCheat
		(
		"Unlimited Grenades",
		&app,
		new TLib::SMemPatch(0x56E984, (LPVOID)nops, 7)
		);

	TLib::SCheat* unlimAmmo = new TLib::SCheat
		(
		"Unlimited Ammo",
		&app,
		new TLib::SMemPatch(0x4C4227, (LPVOID)nops, 3)
		);

	BYTE unlimTankFireRateCode[] = {0x66, 0xc7, 0x06, 0x00, 0x00};
	TLib::SCheat* unlimTankFireRate = new TLib::SCheat
		(
		"Unlimited Tank Cannon Fire Rate",
		&app,
		new TLib::SMemPatch(0x4C3D26, (LPVOID)unlimTankFireRateCode, 5)
		);

	TLib::SCheat* noPlasmaWeapOverheat = new TLib::SCheat("No Overheating for Plasma Weapons", &app);
	noPlasmaWeapOverheat->addPatch(new TLib::SMemPatch(0x004C18EC, (LPVOID)nops, 2));
	noPlasmaWeapOverheat->addPatch(new TLib::SMemPatch(0x004C18E6, (LPVOID)data1, 6));

	TLib::SCheat* invincibility = new TLib::SCheat("Invincibility (Affects Enemy NPC's too)", &app);

	///// For health
	invincibility->addPatch(new TLib::SMemPatch(0x004EF7DF, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EF7E0, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EF7E1, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EF7E2, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EF7E3, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EF7E4, (LPVOID)nops, 1));

	///// For shield
	invincibility->addPatch(new TLib::SMemPatch(0x004EFD9A, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EFD9B, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EFD9C, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EFD9D, (LPVOID)nops, 1));

	invincibility->addPatch(new TLib::SMemPatch(0x004EFE08, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EFE09, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EFE0A, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EFE0B, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EFE0C, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EFE0D, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EFE0E, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EFE0F, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EFE10, (LPVOID)nops, 1));
	invincibility->addPatch(new TLib::SMemPatch(0x004EFE11, (LPVOID)nops, 1));

	app.addCheat(invincibility);
	app.addCheat(unlimNades);
	app.addCheat(unlimAmmo);
	app.addCheat(noPlasmaWeapOverheat);
	app.addCheat(unlimTankFireRate);

	return app.Run();
}